

from apps.verifications.constant import YUNTONGXUN_EXPIRE_TIME
from celery_tasks.main import app
from libs.yuntongxun.sms import CCP
import logging
logger=logging.getLogger('django')

@app.task(bind=True,default_retry_delay=5,name='send_sms')  #default_retry_delay设置时间
def send_sms_code(self,mobile,sms_code):
    try:
         result=CCP().send_template_sms(mobile, [sms_code, YUNTONGXUN_EXPIRE_TIME], 1)
         if result !=0:
             raise Exception('下单失败')
    except Exception as exc:
        logger.error(exc)
        self.retry(exc=exc)
        raise self.retry(exc=exc,mac_retries=3)#设置重试次数
